# Maintainer: Leonidas Spyropoulos <artafinde@archlinux.org>

pkgname=easyloggingpp
pkgver=9.97.0
pkgrel=1
pkgdesc='Efficient logging library for C++ logging library'
arch=('any')
url="https://github.com/amrayn/easyloggingpp"
license=('MIT')
makedepends=(cmake ninja)
makedepends+=(gtest)
source=("$pkgname-$pkgver.tar.gz::https://github.com/muflihun/easyloggingpp/archive/v${pkgver}.tar.gz"
        0001-Switch-CMake-build-system-from-C-11-to-C-14.patch)
sha256sums=('9110638e21ef02428254af8688bf9e766483db8cc2624144aa3c59006907ce22'
            'fefdf8b9742ae11e1ca58f7c3b9f34cb8dab4428ef9be1d916142da076156cf2')
b2sums=('7ae65db33009dccf6e3a4362e4b5e23080935629b079e5898c8063d31144bef2341a041365bf20d0acd5067ad606e752de4b2b70a55f4bd16047b1ae3bab416d'
        'fba88eca30a4e05e3f88dcdb4e758ea87bb2851973d24f4c3c80458fc9b1ae878011407cd9b70168340f1ae4d05a2e0cecdb668900d00e951787498d6fb623f4')

prepare() {
  # https://github.com/amrayn/easyloggingpp/issues/816
  cd "$pkgname-$pkgver"
  patch -Np1 < "${srcdir}/0001-Switch-CMake-build-system-from-C-11-to-C-14.patch"
}

build() {
  cmake \
    -Bbuild \
    -GNinja \
    -S "$pkgname-$pkgver" \
    -DCMAKE_BUILD_TYPE='None' \
    -DCMAKE_INSTALL_PREFIX='/usr' \
    -Dtest=ON \
    -Wno-dev
  cmake --build build --verbose
}

check() {
  cd build && ./easyloggingpp-unit-tests \
    --gtest_filter=-CommandLineArgsTest.LoggingFlagsArg \
    -v
}


package() {
  DESTDIR="${pkgdir}" cmake --install build
  install -Dm644 "${srcdir}/${pkgname}-${pkgver}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}


# vim:set ts=2 sw=2 et:
